#include<bits/stdc++.h>

using namespace std;
int a[10] = {0, 1, 2};//a[i]=i!
int book[10] = {0};//book[i]=1 ʹ����a[i]
//9 111000000
int bucket[1000000 + 1] = {0};

int main() {
    for (int i = 3; i <= 9; i++)a[i] = a[i - 1] * i;

    for (book[1] = 0; book[1] < 2; ++book[1])
        for (book[2] = 0; book[2] < 2; ++book[2])
            for (book[3] = 0; book[3] < 2; ++book[3])
                for (book[4] = 0; book[4] < 2; ++book[4])
                    for (book[5] = 0; book[5] < 2; ++book[5])
                        for (book[6] = 0; book[6] < 2; ++book[6])
                            for (book[7] = 0; book[7] < 2; ++book[7])
                                for (book[8] = 0; book[8] < 2; ++book[8])
                                    for (book[9] = 0; book[9] < 2; ++book[9]) {
                                        int tot = 0;
                                        for (int i = 1; i <= 9; i++) {
                                            if (book[i])tot += a[i];
                                        }
                                        bucket[tot] = 1;
                                    }

    int T;
    cin >> T;
    while (T--) {
        int x;
        cin >> x;
        if (bucket[x] == 1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}
